Repository navigation
fix(cli): refuse to overwrite an existing project in uipath new - #2042
rge-uipath wants to merge 7 commits into
Conversation
Running `uipath new <name>` for a function project in a folder that already had main.py, pyproject.toml or uipath.json silently replaced them. Exit 1 naming the existing files instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Only main.py and uipath.json mark an existing project. A pyproject.toml alone (as written by uv init) is replaced as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
A moderate active finding remains because dangling symlinks can bypass the project-exists guard and allow scaffold files to be written despite the command’s no-overwrite promise.
1 open issue
What changed in this PR
Updates uipath new to protect existing function projects while preserving explicit overwrite behavior.
Changes:
- Refuses overwrite when
main.pyoruipath.jsonexists. - Adds
--forceand tests for refusal, replacement, and barepyproject.toml. - Bumps version to 2.15.16 and refreshes the lockfile.
| File | Description |
|---|---|
packages/uipath/uv.lock |
Records the updated package version and lock metadata. |
packages/uipath/tests/cli/test_new.py |
Covers project overwrite behavior. |
packages/uipath/src/uipath/_cli/cli_new.py |
Implements refusal and force handling. |
packages/uipath/pyproject.toml |
Bumps the package version. |
Review effort: Lite
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
rliuup
left a comment
There was a problem hiding this comment.
Requesting changes because the documented uv init then uipath new quickstart now fails on uv releases that create main.py (head f920ffc), and check-version-availability is red since uipath==2.15.16 is already on PyPI, so this also needs a new patch version.
🚨 Heads up:
|
A pyproject.toml is replaced only when it holds uv's starter keys with uv's default version, description and readme, and at most a uipath dependency, so a configured project is refused before anything is written. The stub main.py that uv 0.11 and earlier write counts as a starter too, so the documented uv init quickstart works again. --force help now names pyproject.toml. Bump to 2.15.17, since 2.15.16 is on PyPI. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
20bfad1 to
38255c1
Compare
nikhil-maryala
left a comment
There was a problem hiding this comment.
Approving. No code blocker at 38255c1. Not run locally; reviewed from the diff.
Earlier comments, all addressed in this head:
- My pyproject.toml comment: the no-force exception now covers only an unmodified
uv initstarter. Other deps, tool config, extra keys, edited values and invalid TOML are refused before any write.--forcehelp now names pyproject.toml. - rliuup, uv stub main.py: an unchanged stub is replaceable. Version is 2.15.17, and 2.15.17 is not on PyPI yet.
- Copilot, dangling symlink:
os.path.lexistsplus a test.
Checked: the guard runs before any file write. Exit code is 1 with a clear message that names the files and --force. Symlinked files are refused, even valid ones. Tests cover each refused case and --force.
Small findings, none blocking:
cli_new.pyUV_STARTER_PROJECT_KEYS:authorsis not allowed. If some uv versions addauthorsfrom git config, the quickstart would be refused. The author says real uv output was checked. Please confirm with a git-configured user.--forceis the workaround.cli_new.py_is_uv_starter: an empty or comment-only pyproject.toml counts as a starter. This is fine, only a note.uv.lock:revision3 to 5 and theexclude-newerlines are unrelated churn from a newer uv. Revert them if easy.- A write that fails halfway can still leave a partial scaffold. The pre-check does not cover this.
--forcehas no test for an existinguipath.jsononly.- CI: the
triage-agentopenai-agents jobs failed. They look unrelated to this diff, not checked.
uv 0.12 and later write authors, [project.scripts] and a uv_build [build-system], so the documented quickstart exited 1. That unmodified starter is now replaced without --force. The uipath dependency match is limited to what uv add writes (uipath or uipath>=X.Y.Z), so an extra or a pin is kept. An edited requires-python is kept too. The lockfile holds only the version change again. Co-Authored-By: Claude <noreply@anthropic.com>
|
🚨 Heads up:
|




uipath new <name>(function projects) silently replaced an existing main.py, pyproject.toml and uipath.json. Now, if any of them holds more than an unmodifieduv initstarter, nothing is written and it exits 1 viaconsole.error, naming the files: "Runuipath newin an empty folder, or pass --force to overwrite." Agent-framework scaffolds are guarded separately (companion: UiPath/uipath-langchain-python#1268).The documented quickstart (
uv init . --python 3.11,uv add uipath,uipath new) still works. A pyproject.toml is replaceable when it holds only uv's[project]keys, uv's default version, description and readme, and at most auipathoruipath>=X.Y.Zdependency. The starter of uv 0.12 and later is replaceable too:authors, one[project.scripts]entry<name> = "<module>:main"and auv_build[build-system]. An extra, a pin or an editedrequires-pythonis refused, and thesrc/<name>/__init__.pythat uv wrote stays in place. The stub main.py that uv 0.11 and earlier write is replaceable when unchanged. Any uipath.json, or a dangling main.py/uipath.json symlink, is refused.--forcekeeps the old in-place overwrite of all three files. It is not forwarded to agent-frameworknewmiddlewares: they take onlynameand live in other packages.Tests: the existing-files test now asserts the refusal; new tests cover
--force, a dangling symlink, the quickstart with and without uv's stub main.py, and refusal of a pyproject.toml with another dependency, tool config, an extra key, an edited version, description or readme, or invalid TOML, an edited stub main.py and an empty uipath.json. Patch version bumped to 2.15.17 (2.15.16 is on PyPI).Verified from packages/uipath:
uv run pytest tests/cli/test_new.py tests/cli/test_job_token.py tests/cli/eval/test_eval_util.py --no-cov,uv run ruff check,uv run ruff format,uv run mypy src/uipath/_cli/cli_new.py, and the realuipath newon folders fromuv initwith uv 0.9.30, 0.11.0 and 0.13.4.🤖 Generated with Claude Code